<?
use WID\Test\Matchers as Matchers;
class toThrowTestException extends Exception {
	function __consturct($message) {
		parent::__construct($message);
	}
}

return array(
	'name'=>'toThrow', 
	
	'each'=> array(
		'matcher'=>null
	),
	
	'beforeEach'=>function(&$each) {
		$each['matcher'] = new Matchers\toThrow();
	}, 
	
	'tests'=>array(
		'match'=>function(&$each) {
			$m = $each['matcher'];
			$this->expect($m->match(function() {
				throw new Exception('test');
			},false,'Exception'))->toBeTrue(); // prawdziwy

			$this->expect($m->match(function() {
				
			},true,'Exception'))->toBeTrue(); // zanegowny prawdziwy
			$this->expect($m->match(function() {
				throw new Exception('test');
			},true,'Exception'))->toBeFalse(); // zanegowany nieprawdziwy
		},
		
		// @TODO matcher toThrow must be fixed.
		'getInfo'=>function(&$each) {
			$this->expect($each['matcher']->getInfo(function() {
			},false,'Exception'))->toBe('|Closure| to throw Exception but nothing throw');
			
			$spy = $this->need->PropertiesSpy->onObject($each['matcher']);
			$spy->setValueOf('LastException')->on(new Exception('test'));
			$this->expect($each['matcher']->getInfo(function() {
				throw new Exception('test');
			},true,null))->toBe('|Closure| not throw but throw Exception');
		},
		
		'getName'=>function(&$each) {
			$this->expect($each['matcher']->getName())->toBe('toThrow');
		}
		
	)
);
?>